#include <bits/stdc++.h>
// 2025/02/28
// tag:
// Author: Forever
using namespace std;

using int64 = int64_t;

int pos[26];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a, b;
    cin >> a >> b;
    for (int i = b.size() - 2; i >= 0; i--)
        if (pos[b[i] - 'a'] == 0)
            pos[b[i] - 'a'] = b.size() - i;
    int ans = INT_MAX, l = 0, r = 0;
    for (int i = 1; i < a.size(); i++) {
        if (pos[a[i] - 'a'] == 0)
            continue;
        if (i + pos[a[i] - 'a'] < ans)
            ans = i + pos[a[i] - 'a'], l = i, r = b.size() - pos[a[i] - 'a'];
    }
    if (ans == INT_MAX) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i <= l; i++)
        cout << a[i];
    for (int i = r + 1; i < b.size(); i++)
        cout << b[i];

    return 0;
}